Untitled7.ipynb
No Headings
The table of contents shows headings in notebooks and supported files.
- File
- Edit
- View
- Run
- Kernel
- Settings
- Help
Kernel status: Idle Executed 2 cellsElapsed time: 240 seconds
- 1
- 2
- 3
[4]:
!pip install pandas numpy scikit-learn matplotlib seaborn
Requirement already satisfied: pandas in c:\users\manju teppala\.ms-ad\lib\site-packages (2.2.2) Requirement already satisfied: numpy in c:\users\manju teppala\.ms-ad\lib\site-packages (1.26.4) Requirement already satisfied: scikit-learn in c:\users\manju teppala\.ms-ad\lib\site-packages (1.5.1) Requirement already satisfied: matplotlib in c:\users\manju teppala\.ms-ad\lib\site-packages (3.9.2) Requirement already satisfied: seaborn in c:\users\manju teppala\.ms-ad\lib\site-packages (0.13.2) Requirement already satisfied: python-dateutil>=2.8.2 in c:\users\manju teppala\.ms-ad\lib\site-packages (from pandas) (2.9.0.post0) Requirement already satisfied: pytz>=2020.1 in c:\users\manju teppala\.ms-ad\lib\site-packages (from pandas) (2024.1) Requirement already satisfied: tzdata>=2022.7 in c:\users\manju teppala\.ms-ad\lib\site-packages (from pandas) (2023.3) Requirement already satisfied: scipy>=1.6.0 in c:\users\manju teppala\.ms-ad\lib\site-packages (from scikit-learn) (1.13.1) Requirement already satisfied: joblib>=1.2.0 in c:\users\manju teppala\.ms-ad\lib\site-packages (from scikit-learn) (1.4.2) Requirement already satisfied: threadpoolctl>=3.1.0 in c:\users\manju teppala\.ms-ad\lib\site-packages (from scikit-learn) (3.5.0) Requirement already satisfied: contourpy>=1.0.1 in c:\users\manju teppala\.ms-ad\lib\site-packages (from matplotlib) (1.2.0) Requirement already satisfied: cycler>=0.10 in c:\users\manju teppala\.ms-ad\lib\site-packages (from matplotlib) (0.11.0) Requirement already satisfied: fonttools>=4.22.0 in c:\users\manju teppala\.ms-ad\lib\site-packages (from matplotlib) (4.51.0) Requirement already satisfied: kiwisolver>=1.3.1 in c:\users\manju teppala\.ms-ad\lib\site-packages (from matplotlib) (1.4.4) Requirement already satisfied: packaging>=20.0 in c:\users\manju teppala\.ms-ad\lib\site-packages (from matplotlib) (24.1) Requirement already satisfied: pillow>=8 in c:\users\manju teppala\.ms-ad\lib\site-packages (from matplotlib) (10.4.0) Requirement already satisfied: pyparsing>=2.3.1 in c:\users\manju teppala\.ms-ad\lib\site-packages (from matplotlib) (3.1.2) Requirement already satisfied: six>=1.5 in c:\users\manju teppala\.ms-ad\lib\site-packages (from python-dateutil>=2.8.2->pandas) (1.16.0)
[10]:
Selection deleted
import matplotlib.pyplot as plt
students = {}
def safe_int(prompt, default=None):
while True:
try:
return int(input(prompt).strip())
except ValueError:
print("Please enter a valid integer.")
def safe_float(prompt):
while True:
try:
return float(input(prompt).strip())
except ValueError:
print("Please enter a valid number (e.g. 78 or 78.5).")
num_students = safe_int("How many students? ")
for s in range(num_students):
name = input(f"\nEnter name of student {s+1}: ").strip() or f"Student_{s+1}"
num_subs = safe_int(f"How many subjects for {name}? ")
marks_dict = {}
if num_subs == 0:
print("Warning: zero subjects — student will have empty marks.")
for i in range(num_subs):
subj = input(f" Enter subject {i+1}: ").strip() or f"Subject_{i+1}"
mark = safe_float(f" Enter marks in {subj}: ")
marks_dict[subj] = mark
students[name] = marks_dict
print("\nStudents Data:")
print(students)
def analyze_marks(marks):
if not marks:
return 0, 0.0, (None, None), (None, None)
total = sum(marks.values())
avg = total / len(marks)
high_sub = max(marks, key=marks.get)
low_sub = min(marks, key=marks.get)
return total, avg, (high_sub, marks[high_sub]), (low_sub, marks[low_sub])
print("\n--- Student Marks Report ---")
for name, marks in students.items():
total, avg, high, low = analyze_marks(marks)
print(f"\nStudent: {name}")
print(f"Subjects & Marks: {marks}")
print(f"Total Marks: {total}")
print(f"Average Marks: {avg:.2f}")
if high[0] is not None:
print(f"Highest: {high[1]} in {high[0]}")
print(f"Lowest : {low[1]} in {low[0]}")
else:
print("No subject marks available.")
if students:
name = input("\nEnter student name to plot marks (or press Enter to skip): ").strip()
if name:
if name in students and students[name]:
marks = students[name]
plt.bar(marks.keys(), marks.values())
plt.title(f"{name} - Marks Chart")
plt.xlabel("Subjects")
plt.ylabel("Marks")
plt.ylim(0, max(marks.values()) + 10)
plt.show()
elif name in students:
print("Student has no marks to plot.")
else:
print("Student not found!")
else:
print("No students available to plot.")
How many students? 3 Enter name of student 1: Veena How many subjects for Veena? 3 Enter subject 1: Maths Enter marks in Maths: 93 Enter subject 2: Science Enter marks in Science: 98 Enter subject 3: Hindi Enter marks in Hindi: 94 Enter name of student 2: Rani How many subjects for Rani? 3 Enter subject 1: Maths Enter marks in Maths: 90 Enter subject 2: Science Enter marks in Science: 97 Enter subject 3: Hindi Enter marks in Hindi: 91 Enter name of student 3: Vani How many subjects for Vani? 3 Enter subject 1: Maths Enter marks in Maths: 96 Enter subject 2: Science Enter marks in Science: 93 Enter subject 3: Hindi Enter marks in Hindi: 99
Students Data:
{'Veena': {'Maths': 93.0, 'Science': 98.0, 'Hindi': 94.0}, 'Rani': {'Maths': 90.0, 'Science': 97.0, 'Hindi': 91.0}, 'Vani': {'Maths': 96.0, 'Science': 93.0, 'Hindi': 99.0}}
--- Student Marks Report ---
Student: Veena
Subjects & Marks: {'Maths': 93.0, 'Science': 98.0, 'Hindi': 94.0}
Total Marks: 285.0
Average Marks: 95.00
Highest: 98.0 in Science
Lowest : 93.0 in Maths
Student: Rani
Subjects & Marks: {'Maths': 90.0, 'Science': 97.0, 'Hindi': 91.0}
Total Marks: 278.0
Average Marks: 92.67
Highest: 97.0 in Science
Lowest : 90.0 in Maths
Student: Vani
Subjects & Marks: {'Maths': 96.0, 'Science': 93.0, 'Hindi': 99.0}
Total Marks: 288.0
Average Marks: 96.00
Highest: 99.0 in Hindi
Lowest : 93.0 in Science
Enter student name to plot marks (or press Enter to skip): Rani
[ ]:
Common Tools
No metadata.
Advanced Tools
No metadata.
Anaconda Assistant
AI-powered coding, insights and debugging in your notebooks.
To enable the following extensions, create an account or sign in.
- Anaconda Assistant4.1.0
- Coming soon!
- Data Catalogs
- Panel Deployments
- Sharing
Already have an account? Sign In
For more information, read our Anaconda Assistant documentation.
![Python [conda env:base] *](./Untitled7_files/logo-64x64.png)